package org.xingyun.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.xingyun.bean.Areas;
import org.xingyun.utils.DataSourcesUtils;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

public class AreaDao {


    public List<Areas> selectAll(String cityid) throws SQLException {
        System.out.println("区域查询MySQL数据了");
        DataSource dataSource = DataSourcesUtils.getDataSource();
        QueryRunner queryRunner = new QueryRunner(dataSource);
        List<Areas> list = queryRunner.query("select * from areas where cityid=?", new BeanListHandler<Areas>(Areas.class), cityid);
        return list;
    }
}
